package com.smart.electronic.fence.controller;

import com.smart.electronic.fence.pojo.ElectronicFence;
import com.smart.electronic.fence.service.ElectronicFenceService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping(value = "/mapbox")
public class MapboxController {

    @Resource
    private ElectronicFenceService fenceService;

    @GetMapping(value = "/{fenceName}")
    public String initMap(@PathVariable String fenceName, ModelMap map){
        System.out.println(fenceName);
        ElectronicFence fence = fenceService.getByName(fenceName);
        map.addAttribute("fence",fence);
        return "map";
    }

}
